package 笔试.顺丰;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class 驼峰命名转下划线命名 {
    // ac
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        List<String> list = new ArrayList<>();
        for (int t = 0; t < n; t++) {
            list.add(sc.nextLine());
        }
        Solution solution = new Solution();
        solution.solve(list);
    }

    static class Solution {
        public void solve(List<String> list) {
            for (int i = 0; i < list.size(); i++) {
                String ans = solve(list.get(i));
                System.out.println(ans);
            }
        }

        public static String solve(String str) {
            ArrayList<Integer> high = new ArrayList<>();
            ArrayList<Integer> line = new ArrayList<>();
            for (int i = 0; i < str.length(); i++) {
                char ch = str.charAt(i);
                if (isHighLetter(ch)) {
                    if (i == 0 || (!high.isEmpty() && high.get(high.size() - 1) == i - 1)) return "indistinct";
                    high.add(i);
                } else if (ch == '_') {
                    if (i == 0 || i == str.length() - 1 || (!line.isEmpty() && line.get(line.size() - 1) == i - 1))
                        return "indistinct";
                    line.add(i);
                }
            }
            if (high.isEmpty()) return str;
            if (!line.isEmpty()) return "indistinct";
            StringBuilder sb = new StringBuilder();
            int start = 0;
            for (int i = 0; i < high.size(); i++) {
                Integer index = high.get(i);
                sb.append(str, start, index);
                sb.append('_');
                sb.append((char) (str.charAt(index) - 'A' + 'a'));
                start = index + 1;
            }
            if (high.get(high.size() - 1) != str.length() - 1) {
                sb.append(str.substring(high.get(high.size() - 1) + 1));
            }

            return sb.toString();
        }

        public static boolean isLowerLetter(Character ch) {
            return ch >= 'a' && ch <= 'z';
        }

        public static boolean isHighLetter(Character ch) {
            return ch >= 'A' && ch <= 'Z';
        }

    }
}
